package li.teng.android.xplanet.content;

import java.util.Locale;

import android.location.Address;
import android.location.Location;

public class MyPosition{
	long id;
	String name;
	double logitude;
	double latitude;
	//Address address; 
	public MyPosition(long _id,String _name,double _logitude,double _latitude){
		id = _id;
		name = _name;
		logitude = _logitude;
		latitude = _latitude;
		//address = new Address(Locale.CHINA);//new Locale(Locale.CHINA)
		//address.setLongitude(_logitude);
		//address.setLatitude(_latitude);	
	}
	
	public long getId(){
		return id;
	}
	
	public String getName(){
		return name;
	}
	
	public double getLogitude(){
		return logitude;
	}
	
	public double getlatitude(){
		return latitude;
	}
	
	@Override
	public String toString(){
		return name;
	}

//	public Location getLocation(){
//		Location ret = new Location()
//		return address
//		
//	}
	float distance;
	float[] dis = new float[3];
	Location mark;
	public float getDistance(Location location){
		if(mark == location)return distance;
		if(mark!= null && mark.getLongitude() == location.getLongitude() && mark.getLatitude() == location.getLatitude())
			return distance;
		Location.distanceBetween(
				location.getLatitude(),location.getLongitude(),
				latitude,logitude,dis);
		distance = dis[0];
		mark = location;
		return distance;
	}
	
	public float getDistance(){
		return distance;
	}
}
